package vip.liux.backend.application.service.gen;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import vip.liux.backend.domain.models.gen.GenTable;
import vip.liux.backend.domain.models.gen.GenTableColumn;
import vip.liux.contracts.infrastructure.automap.IgnoreAudited;
import vip.liux.contracts.infrastructure.automap.MapMapper;
import vip.liux.contracts.infrastructure.automap.MapStructConfig;

import java.util.List;

@Mapper(config = MapStructConfig.class, uses = {MapMapper.class})
public interface AutoMapperProfile {
    AutoMapperProfile INSTANCE = Mappers.getMapper(AutoMapperProfile.class);

    GenTableDto toDto(GenTable source, List<GenTableColumn> columns);

    GenTableColumnDto toDto(GenTableColumn source);

    @IgnoreAudited
    @Mapping(target = "tableId", ignore = true)
    @Mapping(target = "queryType", ignore = true)
    @Mapping(target = "query", ignore = true)
    @Mapping(target = "list", ignore = true)
    @Mapping(target = "javaType", ignore = true)
    @Mapping(target = "javaField", ignore = true)
    @Mapping(target = "insert", ignore = true)
    @Mapping(target = "htmlType", ignore = true)
    @Mapping(target = "edit", ignore = true)
    @Mapping(target = "dictType", ignore = true)
    @Mapping(target = "columnType", ignore = true)
    GenTableColumn toEntity(ColumnDto source);

    @IgnoreAudited
    @Mapping(target = "remark", ignore = true)
    @Mapping(target = "options", ignore = true)
    @Mapping(target = "genType", ignore = true)
    @Mapping(target = "genPath", ignore = true)
    GenTable toEntity(GenTableDto source);
}
